﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Base.Api.Admin.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BaseController : ControllerBase
    {
        /// <summary>
        /// 获取请求IP地址
        /// </summary>
        /// <returns></returns>
        protected string GetIp()
        {
            // return "127.0.0.1";//正式环境请注释  localhost  127.0.0.1  :::1
            IHttpContextAccessor _httpContextAccessor = new HttpContextAccessor();
            return _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();//测试环境请注释
        }
    }
}
